<!DOCTYPE html>
<html>
<head>
<include file="Include:meta" />
<title>项目-目的地运营集团数据管理平台</title>
<include file="Include:style" />
</head>
<body>
<if condition="$project_id eq NULL">
<include file="Include:header" />
<include file="Include:left" />
</if>
<div id="main">
	<!--搜索框-->
	<div class="crumbs">
		<if condition="$project_id eq NULL"><div class="crumbs-text">联系人管理</div></if>
		<div class="right">
			<if condition="$project_id eq NULL">
			<div class="input-group left w200">
		    	<input type="text" id="keyword" value="{$keyword}" class="form-control" style="width:250px;" placeholder="姓名/手机搜索" autocomplete="off">
	    		<span class="input-group-btn">
	        		<button class="btn found_btn" type="button">搜索</button>
		    	</span>
		    </div>
			</if>
			<if condition="$project_id eq NULL and (get_permission('CRML-X',NULL,6) or get_permission('CRML-X',NULL,1) or get_permission('CRML-X',NULL,2) or get_permission('CRML-X',NULL,3))"><!--add_cus-->
				<a href="__APP__/Crm/contact_add" class="btn left ml5">添加联系人</a>
			<else />
				<if condition="get_permission('CRML-X',NULL,6) or get_permission('CRML-X',NULL,1) or get_permission('CRML-X',NULL,2) or get_permission('CRML-X',NULL,3)"><!--add_cus-->
				<a href="javascript:;" class="btn left ml5 add_cus" refresh=1>添加联系人</a>
				</if>
			</if>
		</div>
	</div>
	<div id="content">
		<if condition="$project_id neq NULL">
			<include file="Crm:crm_project_header" />
		</if>
		<div class="table-scrollx">
			<table class="table table-bordered table-hover table-hover-contact">
				<tr class="table-header fixed-table-header">
					<td width="100" class="nowrap">姓名</td>
					<if condition="$type eq 1">
					<td width="300" class="nowrap">
						<select name="project" class="form-control select-add w300">
							<option value="" <if condition="NULL eq $check_project_id">selected</if>>--关联项目--</option>
							<foreach name="project_list" item="co">
								<option value="{$co['project_id']}" <if condition="$check_project_id eq $co['project_id']">selected</if>>{$co['name']}</option>
							</foreach>
						</select>
					</td>
					<else />
					<td width="300" class="nowrap">关联项目</td>
					</if>
					<!-- <td width="200" class="nowrap">关联项目</td> -->
					<td width="50" class="nowrap">联系电话</td>
					<td width="150" class="nowrap">职务</td>
					<!-- <td width="8%" class="nowrap">主要联系人</td> -->
					<td width="80" class="nowrap">决策关系</td>
					<td width="160" class="nowrap">邮箱</td>
					<td width="50">管理</td>
				</tr>
				<if condition="$result eq NULL">
				<tr>
					<td colspan="7" class="text-center">暂无相关内容</td>
				</tr>
				</if>
				<foreach name="result" item="vo">
					<tr>
						<td class="nowrap"><a href="javascript:;" class="detail" mid="{$vo['contact_id']}">{$vo['username']}</a></td>
						<td>{$vo['project_name']}</td>
						<td>{$vo['mobilephone']}</td>
						<td class="nowrap">{$vo['jobinfo']}</td>
						<!-- <td>{$vo['is_main']==1?'<font color="red">是</font>':'否'}</td> -->
						<td>{$vo['decision_relation']}</td>
						<td><a href="mailto:{$vo['email']}">{$vo['email']}</a></td>
						<td class="nowrap">
							<if condition="$project_id eq NULL and ((get_permission('CRML-X',NULL,6) and $vo['add_uid'] eq $login_id) or (get_permission('CRML-X',NULL,1)) or get_permission('CRML-X',NULL,2) or (get_permission('CRML-X',NULL,3) and $vo['add_uid'] eq $login_id ))">
								<a href="__APP__/Crm/contact_edit/contact_id/{$vo['contact_id']}" data-toggle="tooltip" data-placement="left" title="编辑" class="mr5"><i class="glyphicon glyphicon-edit"></i></a>
							<else />
								<if condition="(get_permission('CRML-X',NULL,6) and ($vo['add_uid'] eq $login_id)) or (get_permission('CRML-X',NULL,1)) or get_permission('CRML-X',NULL,2) or (get_permission('CRML-X',NULL,3) and ($vo['add_uid'] eq $login_id))">
								<a href="javascript:;" data-toggle="tooltip" mid="{$vo['contact_id']}" refresh=1 data-placement="left" title="编辑" class="mr5 btn-edit"><i class="glyphicon glyphicon-edit"></i></a>
								</if>
							</if>
						</td>
					</tr>
				</foreach>
			</table>
		</div>
		<div class="pages">{$page}</div>
	</div>
</div>
<!--客户详情-->
<div id="detailModal" class="modal hide fade">
	<div class="modal-dialog w800">
		<div class="modal-content">
			<div class="modal-header">
				<h4 id="myModalLabel">客户详情</h4>
				<i class="fa fa-times" aria-hidden="true" data-dismiss="modal"></i>
			</div>
			<div class="modal-body"></div>
		</div>
	</div>
</div>
<include file="Crm:contact_ajax_add"/>
<include file="Include:javascript" />
<script type="text/javascript">
$(function(){
	//搜索
	$(".found_btn").keywordSearch("__APP__/Crm/contact_list/keyword/$keyword");
	//过滤信息
	$(document).on("change","[name='project']",function(){
		var val = $(this).val();
		window.location.href="__APP__/Crm/contact_list/keyword/{$keyword}/check_project_id/"+val;
	});
	//客户详情
	$(".detail").on("click",function(){
		var mid = $(this).attr("mid");
		$.ajax({
			type:"POST",
			async:false,
			dataType:"json",
			data:{"contact_id":mid},
			url:"__APP__/Crm/contact_detail",
			success:function(data){
				var html = "<table class='table table-bordered'>";
				html+="<tr><td class='side_td' width='10%'>姓名</td><td width='40%'>";
				html+=data.username ? data.username : "";
				html+="</td>";
				html+="<td class='side_td' width='10%'>性别</td><td width='40%'>";
				html+=data.gender ? data.gender : "";
				html+="</td></tr>";
				html+="<tr><td class='side_td'>公司名称</td><td colspan='3'>";
				html+=data.company_name ? data.company_name : "";
				html+="</td></tr>";
				html+="<tr><td class='side_td'>决策关系</td><td>";
				html+=data.decision_relation ? data.decision_relation : "";
				html+="</td><td class='side_td'>地址</td><td>";
				html+=data.addressInfo ? data.addressInfo : "";
				html+="</td></tr>";
				html+="<tr><td class='side_td'>微信号</td><td>";
				html+=data.wx ? data.wx : "";
				html+="</td><td class='side_td'>职位</td><td>";
				html+=data.jobinfo ? data.jobinfo : "";
				html+="</td></tr>";
				html+="<tr><td class='side_td'>手机号</td><td>";
				html+=data.mobilephone ? data.mobilephone : "";
				html+="</td><td class='side_td'>座机号</td><td>";
				html+=data.telephone ? data.telephone : "";
				html+="</td></tr>";
				html+="<tr><td class='side_td'>QQ</td><td>";
				html+=data.qq ? data.qq : "";
				html+="</td><td class='side_td'>邮箱</td><td>";
				html+=data.email ? data.email : "";
				html+="</td></tr>";
				html+="<tr><td class='side_td'>生日</td><td>";
				html+=data.birthday ? data.birthday : "";
				html+="</td><td class='side_td'>爱好</td><td>";
				html+=data.hobby ? data.hobby : "";
				html+="</td></tr>";
				html+="<tr><td class='side_td'>备注</td><td colspan='3'>";
				html+=data.remark ? data.remark : "";
				html+="</td></tr>";
				html+="</table>";
				$("#detailModal").find(".modal-body").html(html).end().modal();
			}
		});
	});
});
</script>
<include file="Crm:javascript_contact"/>
</body>
</html>